#include <iostream>

using std::cout;
using std::endl;

class NonCopyable
{
public:
    NonCopyable()
    {

    }
    NonCopyable(const NonCopyable &rhs) = delete;
    NonCopyable &operator=(const NonCopyable &rhs) = delete;

};

//3、让类继承一个基类，而基类的拷贝构造函数与赋值运算符函数
//被设置为私有的或者直接=delete
class Example
: public NonCopyable
{
public:
    Example()
    {
        cout << "Example()" << endl;
    }


    ~Example()
    {
        cout << "~Example()" << endl;
    }

    //2、将拷贝构造函数与赋值运算符函数设置=delete
    /* Example(const Example &rhs) = delete; */
    /* Example &operator=(const Example &rhs) = delete; */

private:
    //1、将拷贝构造函数与赋值运算符函数设置为私有的
    /* Example(const Example &rhs); */
    /* Example &operator=(const Example &rhs); */
};

void test()
{
    Example ex1;
    Example ex2 = ex1;//error

    Example ex3;
    ex3 = ex1;//error
}

int main(int argc, char *argv[])
{
    test();
    return 0;
}

